Convert block-based timing to day-based timing for improved UX #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the streaming payment contract to use day-based timing instead of block-based timing, making the contract more intuitive for end users while maintaining the same underlying functionality and security guarantees.
Motivation
The original implementation required users to think in terms of blocks (e.g., "stream for 4,320 blocks"), which is not intuitive for non-technical users. By abstracting to days, we provide a better user experience without sacrificing precision or security.
Changes Made
Core Modifications
get-current-day()helper function: Convertsblock-heightto days using the approximation of 144 blocks per daypayment-per-block→payment-per-daystart-block/stop-block→start-day/end-daycalculate-block-delta→calculate-day-deltawith day-based logicstream-to,hash-stream, andupdate-detailsto accept day-based parametersFiles Changed
streaming-payment.clar(all timing-related functions and data structures)Technical Details
(/ block-height u144)to convert blocks to daysTesting Considerations
update-detailswith new parametersImpact
Example Usage
Before:
After: